package com.suwish.pc.adb;

import com.suwish.pc.util.StringUtils;

/**
 * 
 * 构建一条个执行命令。</p>
 * 
 * 使用命令 + 参数的构造方式
 * 
 * @author Min
 *
 */
public class Command {

	private String path = "";
	private String parameter = "";
	/**
	 * 
	 * 使用默认的命令ADB，和给定的参数执行
	 * 
	 * @param parameter
	 */
	public Command(String parameter){
		this(AdbManager.ADB_PATH, parameter);
	}
	public Command(String[] array){
		this(AdbManager.ADB_PATH, array);
	}
	public Command(String cmdPath, String parameter){
		this.path = cmdPath;
		this.parameter = parameter;
	}
	public Command(String cmdPath, String[] array){
		this.path = cmdPath;
		StringBuilder builder = new StringBuilder();
		for(String cmd : array){
			builder.append(cmd + " ");
		}
		parameter = builder.toString();
	}
	/**
	 * 
	 * 将整条命令转化成字符串表示
	 * 
	 * @return
	 */
	public String parseCommand(){
		return (StringUtils.isEmpty(path) ? AdbManager.ADB_PATH : path ) + " " + parameter;
	}
}
